
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.6.0.js"></script>
</head>
<body>
<form action="ResumeAddServlet" method="post">
    <table border="1px">
        <tr>
            <td>姓名:</td>
            <td><input type="text" name="userName" id="userName"><span id="name"></span></td>
        </tr>
        <tr>
            <td>性别:</td>
            <td><input type="radio" name="sex" id="sex" checked value="男">男<input type="radio" name="sex" value="女">女</td>
        </tr>
        <tr>
            <td>籍贯地址:</td>
            <td><input type="text" name="address" id="address"><span id="addre"></span></td>
        </tr>
        <tr>
            <td>出生时间:</td>
            <td><input type="text" name="birth" id="birth"><span>格式:yyyy-MM-dd</span><span id="time"></span> </td>
        </tr>
        <tr>
            <td>联系电话:</td>
            <td><input type="text" name="telephone" id="telephone" onblur="phone()"><span id="phone"></span> </td>
        </tr>
        <tr>
            <td>毕业学校:</td>
            <td><input type="text" name="school" id="school"><span id="schhl"></span> </td>
        </tr>
        <tr>
            <td>简历状态</td>
            <td><input type="radio" value="1" checked name="status">公开<input type="radio" value="0" name="status">保密</td>
        </tr>
        <tr>
            <td>操作:</td>
            <td><input type="submit" value="新增"> <input type="button" onclick="location.href='ResumeListServlet'" value="返回"></td>
        </tr>
    </table>
</form>
<script>
    $(function (){
        $("form").submit(function (){
          if ($("#userName").val().trim()==""){
              $("#name").html('姓名不能为空')
              return false;
          }
          if ($("#address").val().trim()==""){
              $("#addre").html('籍贯地址不能为空')
              return false;
          }
          let reDate = /^\d{4}-\d{1,2}-\d{1,2}$/;
          let birth = $("#birth").val().trim();
          if (!reDate.test(birth)){
              $("#time").html('出生时间不能为空')
              return false;
          }
          if ($("#telephone").val().trim()==""){
              $("#phone").html('电话号码不能为空')
              return false;
          }
          if ($("#school").val().trim()==""){
              $("#schhl").html('毕业学业不能为空');
              return false;
          }
        })
    })
    function phone() {
        $.get("ResumeSelectTelephoneServlet",{telephone:$("#telephone").val()},function (date){
            if (date=="true"){
                $("#phone").text("电话号码不可以使用")
                return false;
            }else {
                $("#phone").text('电话号码可以使用')
            }
        })
    }
</script>
</body>
</html>
